package com.itheima.exception;


import com.itheima.pojo.Result;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result handelException(Exception ex){
        //记录日志
        //通知运维
        //通知开发
        ex.printStackTrace();
        return Result.error(StringUtils.hasLength(ex.getMessage())?ex.getMessage(): "未知错误");
    }
}
